﻿@model WaiGaoQiaoWeb.Models.ConsumablesDetailVM
@{
    ViewBag.Title = "Add";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head
{
  @Html.Css("dp")
    @Html.Js("datepicker")
    <script src="../../Scripts/datepicker-zh.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $("form").makeValidationInline();
            $("#InstockDt1").datepicker({ dateFormat: 'yy-mm-dd' });
            $.post('@Url.Action("RtnGoodsName","Test")', { "Id": $("#Goods_ID").val() }, function (data) {
                $("#Con_GoodsInfoGoodsName").val(data);
                $("#Con_GoodsInfoId").val($("#Goods_ID").val());
            });
            var options = {
                height: 260,
                width: 750,
                url: '@Url.Action("GetDetailListByOrderNo")',
                colModel: [
                    { display: '编号', name: 'ID', width: 60, sortable: false, align: 'left', hide: true, iskey: true },
                    { display: '申请日期', name: 'AppDt', width: 100, sortable: false, hide: false, align: 'left' },
                    { display: '物品名称', name: 'Goods_ID', width: 120, sortable: false, hide: false, align: 'left' },
                    { display: '物品类型', name: 'SpType', width: 120, sortable: false, hide: false, align: 'left' },
                    { display: '数量', name: 'Count', width: 80, sortable: false, hide: false, align: 'left' },
                    { display: '使用人', name: 'UserMan', width: 80, sortable: false, hide: false, align: 'left' },
                    { display: '备注', name: 'Remark', width: 120, sortable: false, hide: false, align: 'left' },
                    { display: '记录日期', name: 'RecordDateTime', width: 100, sortable: false, hide: true, align: 'left' },
                    { display: '操作人', name: 'OperatorID', width: 80, sortable: false, hide: true, align: 'left' },
                    { display: '订单编号', name: 'OrderNo', width: 80, sortable: false, hide: true, align: 'left' }
			      	],
                singleselected: true,
                title: false,
                usepager: true,
                page: 1,
                rp: 5,
                rpOptions: [10, 15],
                showcheckbox: true,
                rowbinddata: true,
                query: $("#OrderNo").val()
            };
            $("#Sporadic_T").flexigrid(options);
            //保存
            $("#btnSave").click(function (event) {

                $("#Goods_ID").val($("#Con_GoodsInfoId").val());
                if (!$("#fmEdit").valid()) {
                    return false;
                }
                $('#fmEdit').ajaxSubmit(function (callback) {
                    if (callback) {
                        refresh();
                    }
                });
            }); // end of btnSave
            //关闭
            $("#btnCancel").click(function (e) {
                if ($("#ID").val() != "0") {
                    CloseModelWindow(null, true);
                    return false;
                }
                if (parent) {
                    for (var i = 0; i < parent.document.frames.length; i++) {
                        if (parent.document.frames[i].document.getElementById("orderno")) {
                            parent.document.frames[i].document.getElementById("orderno").value = $("#OrderNo").val();
                        }
                    }
                    CloseModelWindow(null, true);
                }
            });

            function refresh() {
                showLoadingMsg("保存成功", { left: 400, top: 6 }, true, 3000);
                $("#Sporadic_T").flexOptions(options).flexReload();
            }
        });
       
    </script>
}
@using (Html.BeginForm("Save", "TbtSporadicApp", FormMethod.Post, new { id = "fmEdit" }))
{
    @Html.ValidationSummary(true)
    <div class="mainpanel">
        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.RecordDateTime)
        @Html.HiddenFor(model => model.OperatorID)
        @Html.HiddenFor(model => model.OrderNo)
     
        <table style="width: 98%;">
        <tr>
        <td colspan="4">
        <br />
        </td>
        </tr>
            <tr>
             <td style="text-align: right;"><b>申请日期</b>
                </td>
                <td>@Html.TextBoxFor(model => model.InstockDt1, new { @style = "width:145px;", @ReadOnly = true })
                    @Html.ValidationMessageFor(model => model.InstockDt1)<span style="color: Red;">*</span>
                </td>
                <td style="text-align: right;">@Html.LabelFor(model => model.SpType)
                </td>
                <td>
              @Html.DropDownListFor(model => model.SpType,
                       ViewData["SpType"] as IEnumerable<SelectListItem>,
                            new { @style = "width:152px; height:22px; font-size:13px;" })
                  
                </td>
               </tr>
            <tr>
             <td style="text-align: right;"><b>物品名称</b>
                </td>
                <td>
                    @Html.Partial("RtnSporadicList", new Model.WaiGaoQiao.Con_GoodsInfo())
                    @Html.HiddenFor(model => model.Goods_ID)
                    @Html.ValidationMessageFor(model => model.Goods_ID)<span style="color: Red;">*</span>
                </td>
                
               
                 <td style="text-align: right;">@Html.LabelFor(model => model.Count)
                </td>
                <td>@Html.TextBoxFor(model => model.Count)
                    @Html.ValidationMessageFor(model => model.Count)<span style="color: Red;">*</span>
                </td>
            </tr>
          
            <tr>
            <td style="text-align: right;"><b>使用人</b>
                </td>
                <td>@Html.TextBoxFor(model => model.UserMan)
                    @Html.ValidationMessageFor(model => model.UserMan)<span style="color: Red;">*</span>
                </td>
                <td style="text-align: right;">@Html.LabelFor(model => model.Remark)
                </td>
                <td >@Html.TextBoxFor(model => model.Remark)
                </td>
            </tr>
            <tr style="text-align: center;">
                <td colspan="4" align="center">
                    <a id="btnSave" class="button" href="javascript:void(0);"><span>保 存</span></a> <a
                        id="btnCancel" class="button" href="javascript:void(0);"><span>关 闭</span></a>
                </td>
            </tr>
        </table>
        <div style="width: 820px; overflow-x: scroll;">
            <table id="Sporadic_T" style="display: none;">
            </table>
        </div>
    </div>
}


